#include "LinkQueue.h"
#include <stdio.h>
#include <stdlib.h>
struct LinkQueue
{
    DLlist list;
};
typedef struct LinkQueue LQueue;

LQueue *InitLinkQueue()
{
    LQueue *q = (LQueue*)malloc(sizeof(LQueue));
    if(q == NULL)
        return NULL;
    InitDLlist(&q->list);
    return q;
}

void LQPush(LQueue *q, ElementType element)
{
    InsertTail(&q->list,element);
}

void LQPop(LQueue *q)
{
    RemoveByIndex(&q->list,0,NULL);
}

bool IsQueueEmpty(LQueue *q)
{
    return q->list.len == 0;
}

ElementType *GetLQFront(LQueue *q)
{
    if(q->list.len == 0)
        return NULL;
    return FindByIndex(&q->list,0);
}

int GetQueueLen(LQueue *q)
{
    return q->list.len;
}

void TravelQueue(LQueue *q, void (*funcPtr)(ElementType))
{
    Travel(&q->list,funcPtr);
}

void CleanQueue(LQueue *q,void(*clearPtr)(ElementType))
{
    ClearDLlist(&q->list,clearPtr);
}
